﻿using System.Linq;
using UniMana.Utils.Controls;
using UniMana.Data;
using System;
namespace UniMana.Data
{
    public class Personnel_Personnel_Session_ScheduleInfo
    {
        #region /*Không thay đổi*/
        public bds m_bds = new bds();
        private DBMain m_data = new DBMain();
        public void Save()
        {
            m_data.m_DCSave.SubmitChanges();
        }
        public void Delete()
        {
            m_bds.DeleteCurrent();
            m_data.m_DCSave.SubmitChanges();
        }
        #endregion
        #region [Properties - Thuộc tính]
        public Personnel_Personnel_Session Properties
        {
            get { return m_bds.Current as Personnel_Personnel_Session; }
        }
        #endregion
        public Personnel_Personnel_Session_ScheduleInfo(
            string Personnel = UniMana.Utils.Configs.DefaultConfig.EMPTY_GUID,
            int WorkType = 0,
            DateTime RegistTime = new DateTime(),
            int Session = 0,
            int WeekDay = 0)
        {
            var IQuery = m_data.m_DCSave.Personnel_Personnel_Sessions.Where(tb =>
                                    tb.Personnel_PersonnelKey.ToString() == Personnel &&
                                    tb.Personnel_WorkTypeKey == WorkType &&
                                    tb.RegistTime == RegistTime &&
                                    tb.Training_SessionKey == Session &&
                                    tb.Training_WeekDayKey == WeekDay);
            m_bds.DataSource = IQuery;
            var Row = IQuery.FirstOrDefault();
        }
    }
}
